home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / atanh.c < prev    next >
C/C++ Source or Header  |  1990-04-07  |  865b  |  43 lines

  1. #include <stdio.h>
  2. #include <math.h>
  3. #include "pml.h"
  4. #include "cordic.h"
  5.  
  6. static char     funcname[] = "atanh";
  7.  
  8. extern CORDIC_Table CORDIC_Table1[1];
  9.  
  10. double
  11. atanh(x)
  12.     double          x;
  13. {
  14.     double          x0, y0, z0;
  15.     double          M, X;
  16.     int             E;
  17.     struct exception xcpt;
  18.  
  19.     if (x > MAXDOUBLE || x < -MAXDOUBLE) {
  20.         xcpt.type = UNDERFLOW;
  21.         xcpt.name = funcname;
  22.         xcpt.arg1 = x;
  23.         if (!matherr(&xcpt)) {
  24.             fprintf(stderr, "%s: UNDERFLOW error\n", funcname);
  25.             errno = EDOM;
  26.             xcpt.retval = 0.0;
  27.         }
  28.     }
  29.     else {
  30.         X = 1 - x;
  31.         M = frexp(X, &E);
  32.  
  33.         x0 = 1.0;
  34.         y0 = (2.0 - M - X) / (2.0 + M - X);
  35.         z0 = -E * LN2 * 0.5;
  36.  
  37.         CORDIC_rotate1(0, CORDIC_Table1, &x0, &y0, &z0);
  38.  
  39.         xcpt.retval = z0;
  40.     }
  41.     return (xcpt.retval);
  42. }
  43.